package com.drug.mingkang.service.impl;

import com.drug.mingkang.model.HqFinancing;
import com.drug.mingkang.Mapper.HqFinancingMapper;
import com.drug.mingkang.service.HqFinancingService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 总公司财务(HqFinancing)表服务实现类
 *
 * @author wenchangjian
 * @since 2020-08-11 11:28:42
 */
@Service("hqFinancingService")
public class HqFinancingServiceImpl implements HqFinancingService {
    @Resource
    private HqFinancingMapper hqFinancingMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param handFinancingId 主键
     * @return 实例对象
     */
    @Override
    public HqFinancing queryById(String handFinancingId) {
        return this.hqFinancingMapper.queryById(handFinancingId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<HqFinancing> queryAllByLimit(int offset, int limit) {
        return this.hqFinancingMapper.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param hqFinancing 实例对象
     * @return 实例对象
     */
    @Override
    public HqFinancing insert(HqFinancing hqFinancing) {
        this.hqFinancingMapper.insert(hqFinancing);
        return hqFinancing;
    }

    /**
     * 修改数据
     *
     * @param hqFinancing 实例对象
     * @return 实例对象
     */
    @Override
    public HqFinancing update(HqFinancing hqFinancing) {
        this.hqFinancingMapper.update(hqFinancing);
        return this.queryById(hqFinancing.getHandFinancingId());
    }

    /**
     * 通过主键删除数据
     *
     * @param handFinancingId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(String handFinancingId) {
        return this.hqFinancingMapper.deleteById(handFinancingId) > 0;
    }
}